/*
 * @desc:
 * @Author: 钟强
 * @Date: 2021-11-30 16:46:39
 * @LastEditors: 钟强
 * @LastEditTime: 2021-12-15 17:33:10
 */
import { generateColors } from '@/utils/theme'
import { getItem } from '@/utils/storage'
import { MAIN_COLOR } from '@/constant'
const getters = {
  token: (state) => state.user.token,
  userInfo: state => state.user.userInfo,
  /**
   *
   * @param {*}
   * @returns true 表示存在用户信息
   *
   */
  hasUserInfo: state => {
    return JSON.stringify(state.user.userInfo) !== '{}'
  },
  // 获取动态主题样式
  cssVar: state => {
    return {
      ...state.theme.variables,
      ...generateColors(getItem(MAIN_COLOR))
    }
  },
  // 获取侧边菜单的展开收缩
  sidebarOpened: state => state.app.sidebarOpened,
  language: state => state.app.language,
  mainColor: state => state.theme.mainColor,
  tagsViewList: state => state.app.tagsViewList,
  appConfig: state => state.app.config
}

export default getters
